import request from '@/config/axios'

// 课程素材 VO
export interface MaterialsVO {
  id: number // 主键
  courseId: number // 课程ID
  materialId: number // 素材ID
  orderIndex: number // 素材在课程中的排序索引
}

// 课程素材 API
export const MaterialsApi = {
  // 查询课程素材分页
  getMaterialsPage: async (params: any) => {
    return await request.get({ url: `/course/materials/page`, params })
  },

  // 查询课程素材详情
  getMaterials: async (id: number) => {
    return await request.get({ url: `/course/materials/get?id=` + id })
  },

  // 新增课程素材
  createMaterials: async (data: MaterialsVO) => {
    return await request.post({ url: `/course/materials/create`, data })
  },

  // 修改课程素材
  updateMaterials: async (data: MaterialsVO) => {
    return await request.put({ url: `/course/materials/update`, data })
  },

  // 删除课程素材
  deleteMaterials: async (id: number) => {
    return await request.delete({ url: `/course/materials/delete?id=` + id })
  },

  // 导出课程素材 Excel
  exportMaterials: async (params) => {
    return await request.download({ url: `/course/materials/export-excel`, params })
  },
}